package com.lehecai.core.lottery;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lehecai.core.IntegerBeanLabelItem;


public class LimitNumberType extends IntegerBeanLabelItem {

	private static final long serialVersionUID = 1L;
	private static final Logger logger = LoggerFactory.getLogger(LimitNumberType.class.getName());
	
	private static List<LimitNumberType> items = new ArrayList<LimitNumberType>();
	private static List<LimitNumberType> queryItems = new ArrayList<LimitNumberType>();
	

	protected LimitNumberType(String name, int value, boolean queryOnly) {
		super(LimitNumberType.class.getName(), name, value);
		
		queryItems.add(this);
		if (!queryOnly) {
			items.add(this);
		}
	}
	
	protected LimitNumberType(String name, int value) {
		this(name, value, false);
	}
	
	public static List<LimitNumberType> getItems() {
		return items;
	}
	
	public static List<LimitNumberType> getItemsForQuery() {
		return queryItems;
	}

	public static LimitNumberType getItem(int value){
		try {
			return (LimitNumberType)LimitNumberType.getResult(LimitNumberType.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}
	
	public static final LimitNumberType ALL = new LimitNumberType("全部", -1, true);
	
	public static final LimitNumberType DESIGNATION_PHASE = new LimitNumberType("指定期有效", 1);
	public static final LimitNumberType END_DESIGNATION_PHASE = new LimitNumberType("截止到指定期有效", 2);
	public static final LimitNumberType END_THE_TIME = new LimitNumberType("截止到指定时间有效", 3);
	
}
